Created
May 27, 2015 11:09
-
-
Save hgomersall/cf8a47e7f6929564addd to your computer and use it in GitHub Desktop.
Concat converts to VHDL with no explicit unsign
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 twiddler(sig_in, sig_out, clock, reset): | |
concat_sig_in = ConcatSignal(sig_in(5, 0), intbv(0)[5:]) | |
@always_seq(clock.posedge, reset=reset) | |
def twiddle(): | |
sig_out.next = concat_sig_in.signed() | |
return twiddle | |
clock = Signal(bool(0)) | |
reset = ResetSignal(0, active=1, async=False) | |
signal_in = Signal(intbv(0, min=-511, max=512)) | |
signal_out = Signal(intbv(0, min=-511, max=512)) | |
toVHDL(twiddler, signal_in, signal_out, clock, reset) |
Workaround:
def twiddler(sig_in, sig_out, clock, reset):
unsigned_sig_in = Signal(intbv(0)[len(sig_in):])
concat_sig_in = ConcatSignal(unsigned_sig_in(5, 0), intbv(0)[5:])
@always_comb
def assignments():
unsigned_sig_in.next = sig_in
@always_seq(clock.posedge, reset=reset)
def twiddle():
sig_out.next = concat_sig_in.signed()
return twiddle, assignments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The above outputs the following VHDL:
Notice that the assignment
concat_sig_in(10-1 downto 5) <= signal_in(5-1 downto 0);
has two issues.