`include "my_struct_s.v"
typedef struct packed {
logic [17-1:0] instr;
logic [10-1:0] addr;
} instr_packet_s;
module fifo#(parameter I_WIDTH=17, A_WIDTH=10, LG_DEPTH=3)
(
input clk,
input instr_packet_s instr_packet_i, // down
input enque_i,
input deque_i,
input clear_i,
output instr_packet_s instr_packet_o, // up
output empty_o,
output full_o,
output valid_o
);
instr_packet_s ip_in;
assign ip_in.addr = pc_r;
assign ip_in.instr = ram_data;
assign ip_in = '{addr: pc_r, instr:ram_data};
instr_packet_s ip_out;
assign instruction_addr_o = ip_out.addr;
assign instruction_data_o = ip_out.instr;
// assign '{addr: instruction_addr_o, instr: instruction_data_o} = ip_out;
// assign { instruction_addr_o, instruction_data_o } = ip_out;
fifo fetch_fifo
(
.clk(clk)
,.instr_packet_i(ip_in)
,.deque_i(dequeue_i)
,.clear_i(fifo_clear)
,.enque_i(fifo_enqueue)
,.instr_packet_o(ip_out)
,.empty_o(fifo_empty)
,.full_o(fifo_full)
,.valid_o(fifo_valid)
);
# ** Warning: (vsim-3017) Z:/Documents/UCSD/CSE 141L/Processor/
test.tfw(44): [TFMPC] - Too few port connections. Expected 18, found 11.
// original structure
my_struct_s my_struct = ...
// flattened structure
wire [$bits(my_struct_s)-1:0] my_struct_flat;
assign my_struct_flat = my_struct; // convert struct to flattened struct
wire [$bits(my_struct_s)-1:0] my_struct_flat = ... ;
my_struct_s my_struct;
assign my_struct = my_struct_flat; // converted flattened struct to real struct
// *************************************************
// tb: nonsynthesizable; in tb.v
// tb is our testbench
`include "my_struct_s.v"
module tb ();
my_struct_s in, out;
.. code here ..
core mycore (.my_struct_i(in), .my_struct_i(out));
endmodule
// *************************************************
// core: synthesizable; in core.v
// core is the module we are actually creating
`include "my_struct_s.v"
module core
( input my_struct_s my_struct_i
,output my_struct_s my_struct_o
);
.. code here ..
endmodule
// *************************************************
// tb: nonsynthesizable; in tb.v
// tb is our testbench
`include "my_struct_s.v"
module tb ();
my_struct_s in, out;
logic [$bits(my_struct_s)-1:0] in_flat, out_flat;
assign in_flat = in;
assign out = out_flat;
..
core mycore (.my_struct_flat_i(in_flat), .my_struct_flat_o(out_flat));
endmodule
// *************************************************
// core: synthesizable; in core.v
// core is the module we are actually creating
`include "my_struct_s.v"
module core
( input [$bits(my_struct_s)-1:0] my_struct_flat_i // flattened struct params of synth module
,output [$bits(my_struct_s)-1:0] my_struct_flat_o // flattened struct params of synth module
);
my_struct_s my_struct_i, my_struct_o; // the actual structs
assign my_struct_i = my_struct_flat_i; // unflattened in param
assign my_struct_flat_o = my_struct_o; // unflattened out param
.. code here ..
endmodule