Created
May 22, 2013 16:43
-
-
Save strfry/5629038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import * | |
def SRL16E( | |
CLK, CE, | |
D, | |
A, | |
Q): | |
reg = Signal(intbv()[16:0]) | |
@always_comb | |
def comb(): | |
Q.next = reg[A] | |
@always(CLK.posedge) | |
def seq(): | |
if CE: | |
reg.next = concat(reg[16:1], D) | |
return instances() | |
def convert(): | |
CLK = Signal(False) | |
CE = Signal(False) | |
D = Signal(False) | |
Q = Signal(False) | |
A = Signal(intbv()[4:0]) | |
toVerilog(SRL16E, CLK, CE, D, A, Q) | |
convert() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File: SRL16E.v | |
// Generated by MyHDL 0.7 | |
// Date: Wed May 22 18:41:54 2013 | |
`timescale 1ns/10ps | |
module SRL16E ( | |
CLK, | |
CE, | |
D, | |
A, | |
Q | |
); | |
input CLK; | |
input CE; | |
input D; | |
input [3:0] A; | |
output Q; | |
wire Q; | |
reg [15:0] reg; | |
always @(posedge CLK) begin: SRL16E_SEQ | |
if (CE) begin | |
reg <= {reg[16-1:1], D}; | |
end | |
end | |
assign Q = reg[A]; | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment