i'm implementing an instance of single cycle MIPS processor. i want to implement store half-word and store byte
I've added a new input signal to my "Data memory" to control what to store like the code below.
// this was prof. Harris implementation in "digital design and computer
// architecture book" implementation before i turn the "we" (Write Enable) signal into 2 bits
module dmem(input logic clk, [1:0]we, //where we is an output of the control unit
input logic [31:0] a, wd,
output logic [31:0] rd);
logic [31:0] RAM[63:0];
assign rd = RAM[a[31:2]]; // word aligned
always_ff @(posedge clk)
case(we)
2'b01: RAM[a[31:2]] <= wd; // sw
2'b10: RAM[a[31:0]][15:0] <= wd[15:0]; // sh
2'b11: RAM[a[31:0]][7:0] <= wd[7:0]; // sb
default:
// do nothing
...
is this realistic if it's not what is the conventional way to implement it?
I'm studying it as a hobby, sorry if my question seems to be stupid