Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
verilog code for ternary content addressable memory
#1

verilog code for ternary content addressable memory

Content Addressable Memory (CAM)

space.gif

1 //--
2 // Design Name : cam
3 // File Name : cam.v
4 // Function : CAM
5 // Coder : Deepak Kumar Tala
6 //--
7 module cam (
8 clk , // Cam clock
9 cam_enable , // Cam enable
10 cam_data_in , // Cam data to match
11 cam_hit_out , // Cam match has happened
12 cam_addr_out // Cam output address
13 );
14
15 parameter ADDR_WIDTH = 8;
16 parameter DEPTH = 1 << ADDR_WIDTH;
17 //--Input Ports--
18 input clk;
19 input cam_enable;
20 input [DEPTH-1:0] cam_data_in;
21 //--Output Ports--
22 output cam_hit_out;
23 output [ADDR_WIDTH-1:0] cam_addr_out;
24 //--Internal Variables--
25 reg [ADDR_WIDTH-1:0] cam_addr_out;
26 reg cam_hit_out;
27 reg [ADDR_WIDTH-1:0] cam_addr_combo;
28 reg cam_hit_combo;
29 reg found_match;
30 integer i;
31 //--Code Starts Here--
32 always @(cam_data_in) begin
33 cam_addr_combo = {ADDR_WIDTH{1'b0}};
34 found_match = 1'b0;
35 cam_hit_combo = 1'b0;
36 for (i=0; i<DEPTH; i=i+1) begin
37 if (cam_data_in[i] && ! found_match) begin
38 found_match = 1'b1;
39 cam_hit_combo = 1'b1;
40 cam_addr_combo = i;
41 end else begin
42 found_match = found_match;
43 cam_hit_combo = cam_hit_combo;
44 cam_addr_combo = cam_addr_combo;
45 end
46 end
47 end
48
49 // Register the outputs
50 always @(posedge clk) begin
51 if (cam_enable) begin
52 cam_hit_out <= cam_hit_combo;
53 cam_addr_out <= cam_addr_combo;
54 end else begin
55 cam_hit_out <= 1'b0;
56 cam_addr_out <= {ADDR_WIDTH{1'b0}};
57 end
58 end
59
60 endmodule
Reply

#2
Verilog CODE-

//--
//
// Title : decoder2_4
// Design : verilog upload
// Author : Naresh Singh Dobal
// Company : nsd
//
//--
//
// File : 2 to 4 Decoder using Conditional Operator.v

module decoder2_4 ( din ,dout );

output [3:0] dout ;

input [1:0] din ;

assign dout[3] = din==2'b00 ? 1'b1 : 1'b0;
assign dout[2] = din==2'b01 ? 1'b1 : 1'b0;
assign dout[1] = din==2'b10 ? 1'b1 : 1'b0;
assign dout[0] = din==2'b11 ? 1'b1 : 1'b0;

endmodule
Reply

#3
Hi am Mohamed i would like to get details on verilog code for ternary content addressable memory ..My friend Justin said verilog code for ternary content addressable memory will be available here and now i am living at .. and i last studied in the college/school .. and now am doing ..i need help
Reply

#4
sir,
please send me the verilog code for TCAM using reversible logic.

Thank you
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.