[讨论] 数值精确度询问

楼主: liboligo (liboligo)   2018-11-19 12:07:26
各位前辈好
前情摘要:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
a=fi(3,0,2,0); % a= "11" in binary
b=fi(1,0,2,0); % b= "01" in binary
c=a+b; % matlab运算结果c会等于4
% 并用存成fi(4,0,3,0);的形式
% c= “100“ in binary
而如果我去修改c的精确度,把c也用2 bit存
c= fi(c,0,2,0); % c=“11“ in binary
% c会被存成2bit最大数
‰%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
想请问:
不知道有没有办法把c修改成一样2 bit时,
让c抓到的是后面的2 bit “00“ ?
而不是因为实际数字大于2 bit所表示范围
而自动抓到2 bit "11"最大数 。
动机:
由于小弟写RTL要设计精确度
想说用matlab来先模拟
有请各位前辈指教~
作者: sppmg (sppmg)   2018-11-19 12:55:00
没用过fi(),不过何不用 bitand ?

Links booklink

Contact Us: admin [ a t ] ucptt.com