All pastes #403013 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-03-20 03:30 UTC
rendered paste body
// Implements as 86 LEs for ACEX1K (chip has total 576 LEs)

module step(clk, hold, step, direction, position, ivelocity);
parameter q=20;
parameter r=12;
input clk, hold;
output step, direction;
input [q-1:0] ivelocity;
output [q+r-1:0] position; reg [q+r-1:0] position;
reg [q-1:0] velocity;

wire [r-1:0] xvelocity = {r{velocity[q-1]}};
wire [q+r-1:0] hvelocity = {xvelocity, velocity};
assign step=position[q-1];
assign direction=velocity[q-1];

always @(posedge clk)
    velocity <= ivelocity;

always @(posedge clk)
    if(!hold)
        position <= position + hvelocity;

endmodule