mY GOAL IS TO THE GET THE DATA AS INPUT AND STORE IT IN THE MEMORY I am storing it in Fetch_Memory and later and I am increment the pC value for every clock edge, i am doing a asynchronous read from the memory for the respective value.
input clk;
input [31:0] din;
input reset;
reg [31:0] PC = 31'b0;
output reg [31:0] IR;
integer counter = 512'b0;
parameter data_width = 32;
parameter data_depth = 512;
always @(posedge clk)
begin
if(reset)
begin
counter <= 512'b0;
PC <= 32'd0;
// IR <= 32'd0;
end
else
begin
Fetch_Memory[PC] <= din;//din;
counter <= counter + 512'h1;
PC <= PC + 32'd1; //32'h00000001;
// IR <= Fetch_Memory[counter];
end
end
always @(posedge reset)
begin
IR <= 32'b0;
end
**// thE PROBLEM IS iN HERE i AM gETIING xxxx VALUES IN THE IR REGISTER**
always @(PC)
begin
IR = Fetch_Memory[PC];
end
endmodule
*`Here I am ADDING TH**E tEST BENCH TOO**`**
parameter data_depth = 512;
parameter data_width = 32;
// Inputs
reg clk;
reg [31:0] din;
reg [31:0] PC;
reg reset;
// Outputs
reg [31:0] IR;
integer counter ;
reg [data_width-1:0] Fetch_Memory [data_depth-1:0];
always
begin
#5 clk = ~clk;
end
initial begin
// Initialize Inputs
#0 reset = 1;
#15 reset =0;
clk = 1'b0;
din = 32'h25645878;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here
end
You have IR being set in two always
blocks; this is not possible in synthesis, as it does not model a hardware component.
always @(posedge reset)
begin
IR <= 32'b0;
end
// thE PROBLEM IS iN HERE i AM gETIING xxxx VALUES IN THE IR REGISTER**
always @(PC)
begin
IR = Fetch_Memory[PC];
end
For a combinatorial (asynch) lookup just use:
always @* begin
IR = Fetch_Memory[PC];
end
If IR is still X, it has to do with writing data to Fetch_Memory
.