Forum Discussion
NCO help...
Hi i'm trying to test a fixed point filter on a FPGA board, my filter has an input of 16 bit, but the maximum value it can take without saturation is 1023 which is 11 bits. so far the only signal i've been using to is the NCO megafunction. when i set the NCO to have a magnitude of 16 bits i get severe distortion and loss of precision, i cant change the NCO to have a smaller number of bits or i get a bit mismatch, and i cant reduce the number of bits of the filter because i get distortion and loss of precision again. i'm using simulink and fixed point advisor in simulink to design this filter....
Can anyone please help..? not sure if there is another way to test the filter with a more dynamic signal. or if anyone is familiar with simulink how i can optimize my design.36 Replies
- Altera_Forum
Honored Contributor
If you have say A = 8 bits signed and you connect it to B = 12 bits signed then you connect 8 LSBs of A to 8 LSBs of B.
But the remaining 4 MSBs of B must not be zeroed, but must follow sign bit of A. e.g. 0000 1111 = + 15 on 8 bits 0000 0000 1111 = +15 on 12 bits 1111 0001 = - 15 on 8 bits 1111 1111 0001 = -15 on 12 bits Hope it is clear. - Altera_Forum
Honored Contributor
--- Quote Start --- If you are working on schematics then just connect MSB of NCO to all remaing MSBs of filter input. if you want VHDL then: sine16 = std_logic_vector(resize(signed(sine11),16)); You can also keep your NCO on 16 bits then select its 11 MSBs instead of setting it to 11 bits., your choice ... --- Quote End --- Wouldnt this give me a width mismatch? because i'm not sure exactly how i would do this can i get an example...i'm talking about schematic way. - Altera_Forum
Honored Contributor
And the other option is to rescale your coeffs so that you get unity gain, set their sum to 2^15 ( or 1.0 normalised)
- Altera_Forum
Honored Contributor
If you are working on schematics then just connect MSB of NCO to all remaing MSBs of filter input.
if you want VHDL then: sine16 = std_logic_vector(resize(signed(sine11),16)); You can also keep your NCO on 16 bits then select its 11 MSBs instead of setting it to 11 bits., your choice ... - Altera_Forum
Honored Contributor
How do you do sign extension?
- Altera_Forum
Honored Contributor
A short cut is to set NCO to 10 bits then sign extend its output to16 bits