Hi All,
I am new to systemverilog. Before joining fpga world, I mainly work on java server side development.
Now, I have an Avalon-ST output for data streaming. I have to create a data decoder by this Avalon interface.
What I have now is : a list of input and output ports:
localparam SIZE = 48;
localparam WIDTH = 256;
// reset & clk
input logic reset_n,
input logic clk,
// Avalon ST output
output logic ready_out,
// Avalon ST input
input logic in_vld,
input logic in_sop,
input logic in_eop,
input logic [WIDTH-1:0] in_data, // WIDTH = data width of Avalon ST
input logic [4:0] in_eop_pos,
and I have to create a output packet:
// output packet
// a business message contain max 1500 bytes, so it will be fit into WIDTH * 48 bits
output logic [WIDTH*SIZE-1:0] msg_packet
I know I have to create a FSM for message decoding.
I created it and I used ModelSim to simulate it and seems everything work fine.
typedef struct {
logic[DATA_WIDTH-1:0] data;
logic[4:0] eop_pos;
} in_packet;
in_packet in_packets[$];
in_packet the_packet;
always_ff @(posedge clk or negedge reset_n) begin
$strobe("%g\tstate=%b, in_packet.size=%2d", $time, state, in_packets.size());
....
if (in_vld) begin
// add in_data to queue
// I am using blocking assignment here
the_packet.data = in_data;
the_packet.eop_pos = in_eop_pos;
in_packets.push_back(the_packet);
end
....
end
You can checkout it from eda playground:
avalon fsm (va) - EDA Playground
However, there is one thing I am not sure.
All HDL tutorials teach us not to use blocking assignment inside flip flop.
What if I want to add data to queue inside flip flop? I use blocking assignment here.
Am I correct? What’s the appropriate way to push_back queue inside flip flop?
Regards,
Ken