Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
7 years ago

lpm functions and hdl

Hi all,

So I'm trying to create a (synchronous) 8-bit loadable counter, as below but for some reason this synthesizes to around 28 LE's compared to the altera LPM 11 LE version. Any idea why?

Thanks!

-Mux

module register8 (

clk,

clken,

reset_n,

data,

load,

cnt_en,

updown,

q,

q_next

);

input clk;

input clken;

input reset_n;

input [7:0] data;

input load;

input cnt_en;

input updown;

output [7:0] q, q_next;

reg [7:0] addsub;

always @(*)

if ( updown )

addsub = q - 8'd1;

else

addsub = q + 8'd1;

// asynchronous 'next' value. This is used extensively for flags

reg [7:0] q, q_next;

always @(*)

if ( load )

q_next = data;

else

begin

if ( cnt_en )

q_next = addsub;

else

q_next = q;

end

always @(posedge clk or negedge reset_n )

if ( !reset_n )

q <= 8'd0;

else if ( clken )

q <= q_next;

endmodule

12 Replies