Skip to content

Commit

Permalink
Ignition: make controller deserialization event mux configurable, dia…
Browse files Browse the repository at this point in the history
…grams, documentation
  • Loading branch information
arjenroodselaar committed Oct 12, 2024
1 parent 3ade924 commit ae1e0c6
Show file tree
Hide file tree
Showing 9 changed files with 182 additions and 207 deletions.
4 changes: 4 additions & 0 deletions hdl/ip/bsv/ignition/Ignition Controller Receiver.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions hdl/ip/bsv/ignition/Ignition Controller.drawio.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 27 additions & 27 deletions hdl/ip/bsv/ignition/IgnitionController.bsv
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ module mkController #(
// Event handler state
Reg#(EventHandlerState) event_handler_state <- mkReg(AwaitingEvent);
Reg#(EventHandlerState) event_handler_select <- mkRegU();
Reg#(ControllerId#(n)) current_controller <- mkRegU();
Reg#(ControllerId#(n)) controller_id <- mkRegU();

PulseWire tick <- mkPulseWire();
Reg#(UInt#(10)) tick_count <- mkReg(0);
Expand Down Expand Up @@ -384,11 +384,11 @@ module mkController #(

function Action count_application_events(
CountableApplicationEvents events) =
event_counters.count_application_events(current_controller, events);
event_counters.count_application_events(controller_id, events);

function Action count_transceiver_events(
CountableTransceiverEvents events) =
event_counters.count_transceiver_events(current_controller, events);
event_counters.count_transceiver_events(controller_id, events);

(* fire_when_enabled *)
rule do_start_event_handler (
Expand Down Expand Up @@ -416,7 +416,7 @@ module mkController #(
// setting the id in all register files. This will automatically cause a
// read of each register file on the next clock cycle.
if (maybe_controller_id matches tagged Valid .id) begin
current_controller <= id;
controller_id <= id;

presence.select(id);
transceiver.select(id);
Expand All @@ -431,14 +431,14 @@ module mkController #(
target_link1_status.select(id);
target_link1_events.select(id);

event_handler_state <= ReadingRegisters;
event_handler_state <= AwaitingControllerDataValid;
end
endrule

(* fire_when_enabled *)
rule do_read_registers (
init_complete &&
event_handler_state == ReadingRegisters);
event_handler_state == AwaitingControllerDataValid);
// Select the appropriate handler.
event_handler_state <= event_handler_select;
endrule
Expand Down Expand Up @@ -515,20 +515,20 @@ module mkController #(

$display("%5t [Controller %02d] Transmitter output enable mode ",
$time,
current_controller,
controller_id,
fshow(transceiver_.transmitter_output_enable_mode));

if (transceiver.transmitter_output_enabled &&
!transceiver_.transmitter_output_enabled) begin
$display("%5t [Controller %02d] Transmitter output disabled",
$time,
current_controller);
controller_id);
end
else if (!transceiver.transmitter_output_enabled &&
transceiver_.transmitter_output_enabled) begin
$display("%5t [Controller %02d] Transmitter output enabled",
$time,
current_controller);
controller_id);
end

// Update the transceiver register. Any changes are applied on
Expand Down Expand Up @@ -565,11 +565,11 @@ module mkController #(
maybe_request matches tagged Valid .request) begin
$display("%5t [Controller %02d] Requesting ",
$time,
current_controller, fshow(request));
controller_id, fshow(request));

transmitter_events.enq(
TransmitterEvent {
id: current_controller,
id: controller_id,
ev: tagged Message tagged Request request});

count_application_events(
Expand Down Expand Up @@ -612,7 +612,7 @@ module mkController #(
if (presence.status_message_timeout_ticks_remaining == 0) begin
$display("%5t [Controller %02d] Target Status timeout",
$time,
current_controller);
controller_id);

// Add a timeout to the presence history.
presence_.history = shiftInAt0(presence.history, False);
Expand All @@ -633,15 +633,15 @@ module mkController #(
if (pack(presence_.history) == 'b000 && presence.present) begin
$display("%5t [Controller %02d] Target not present",
$time,
current_controller);
controller_id);

target_timeout = True;
presence_.present = False;
end

// Write back the presence state.
presence <= presence_;
presence_summary_r[current_controller] <= presence_.present;
presence_summary_r[controller_id] <= presence_.present;

// Count down until the next Hello.
if (hello_timer.ticks_remaining == 0) begin
Expand Down Expand Up @@ -675,7 +675,7 @@ module mkController #(
transceiver.transmitter_output_disable_timeout_ticks_remaining == 1) begin
$display("%5t [Controller %02d] Transmitter output disabled",
$time,
current_controller);
controller_id);

transceiver_.transmitter_output_enabled = False;
end
Expand All @@ -687,11 +687,11 @@ module mkController #(
if (hello_timer.ticks_remaining == 0) begin
$display("%5t [Controller %02d] Hello",
$time,
current_controller);
controller_id);

transmitter_events.enq(
TransmitterEvent {
id: current_controller,
id: controller_id,
ev: tagged Message tagged Hello});

hello_sent = True;
Expand All @@ -703,7 +703,7 @@ module mkController #(
else begin
transmitter_events.enq(
TransmitterEvent {
id: current_controller,
id: controller_id,
ev: tagged OutputEnabled
transceiver_.transmitter_output_enabled});
end
Expand Down Expand Up @@ -734,7 +734,7 @@ module mkController #(
tagged TargetStatusReceived: begin
$display("%5t [Controller %02d] Received Status",
$time,
current_controller);
controller_id);

PresenceRegister presence_ = presence;
Bool target_present = False;
Expand All @@ -755,15 +755,15 @@ module mkController #(
!presence.present) begin
$display("%5t [Controller %02d] Target present",
$time,
current_controller);
controller_id);

presence_.present = True;
target_present = True;
end

// Write back the presence state.
presence <= presence_;
presence_summary_r[current_controller] <= presence_.present;
presence_summary_r[controller_id] <= presence_.present;

// Update the transmitter output enabled state if configured.
// The actual TransmitterEvent will be sent on the next tick.
Expand All @@ -776,7 +776,7 @@ module mkController #(
presence_.present) begin
$display("%5t [Controller %02d] Transmitter output enabled",
$time,
current_controller);
controller_id);

transceiver_.transmitter_output_enabled = True;
transceiver_.transmitter_output_disable_timeout_ticks_remaining = 0;
Expand All @@ -798,7 +798,7 @@ module mkController #(
let current = presence_.current_status_message;

event_counters.count_target_link0_events(
current_controller,
controller_id,
determine_transceiver_events(
target_link0_status[previous],
target_link0_status[current],
Expand All @@ -815,7 +815,7 @@ module mkController #(
True));

event_counters.count_target_link1_events(
current_controller,
controller_id,
determine_transceiver_events(
target_link1_status[previous],
target_link1_status[current],
Expand Down Expand Up @@ -890,7 +890,7 @@ module mkController #(
tagged ReceiverReset: begin
$display("%5t [Controller %02d] Receiver reset",
$time,
current_controller);
controller_id);

TransceiverRegister transceiver_ = transceiver;

Expand Down Expand Up @@ -924,7 +924,7 @@ module mkController #(
current_status.receiver_aligned) begin
$display("%5t [Controller %02d] Transmitter output enabled",
$time,
current_controller);
controller_id);

transceiver_.transmitter_output_enabled = True;
transceiver_.transmitter_output_disable_timeout_ticks_remaining = 0;
Expand Down Expand Up @@ -1053,7 +1053,7 @@ typedef struct {

typedef enum {
AwaitingEvent = 0,
ReadingRegisters,
AwaitingControllerDataValid,
HandlingSoftwareRequest,
HandlingTickEvent,
HandlingReceiverEvent
Expand Down
Loading

0 comments on commit ae1e0c6

Please sign in to comment.