Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

Desinging a content addressable memory (cam) in verilog

currently learning verilog and what I'm trying to do is designing a content addressable memory (cam) in the following ways:

  1. Fully parallel
  2. Bit serial - Word parallel
  3. Bit parallel - Word serial

So far I've managed to implement the first one, but having a hard time to implement the other two since I'm pretty new to this. Here is what I've done so far for the first type:

module pp_cam(
    ck,   // clock
    en,   // enable
    din,  // content value
    dout  // content location
);

parameter ADDR_WIDTH  = 2;
parameter DEPTH       = 1 << ADDR_WIDTH;

input ck, en;
input [3:0] din;
output reg [ADDR_WIDTH-1:0] dout;

reg [3:0] mem [DEPTH-1:0];
reg [ADDR_WIDTH-1:0] loc;
integer i;

initial begin
    mem[0] = 4'b1101; // 13
    mem[1] = 4'b1100; // 12
    mem[2] = 4'b0101; // 5
    mem[3] = 4'b0001; // 1
end

always @(din) begin
    loc = {ADDR_WIDTH{1'bx}};
    for (i = 0; i < DEPTH; i = i+1) begin
        if (mem[i] == din)
          loc = i;
    end
end
    
always @(posedge ck) begin
    if (en)
        dout <= loc;
        $display("%b", loc);
    else
        dout <= {ADDR_WIDTH{1'bx}};
end

endmodule

Looking forward to implement the other two types based on the first implementation, but got stuck. Any help or tips that could help me would be much appreciated.

question from:https://stackoverflow.com/questions/65944662/desinging-a-content-addressable-memory-cam-in-verilog

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...