Commit 79c7f4db authored by Benoit Rat's avatar Benoit Rat

c_headers: add the signess specification

When using:

* sign=0 (We are using unsigned field)
* sign=1 (We are using the most significant bit to give the signess)
* sign=2 (We are using two complements signess)

For example if we have 8bits we will have:

* sign=0 => val=[0,255]
* sign=1 => val=[-127,127]
* sign=2 => val=[-128,127] //because we don't have 0 and -0
parent 0f48e043
......@@ -30,6 +30,14 @@ function cgen_c_field_define(field, reg, index)
field.nbfp=0;
end
if(field.sign == nil) then
if (field.nbfp > 0) then
field.sign=2; --For fixed point by default we use 2complements signess
else
field.sign=0; --Otherwise we use unsigned
end
end
emit("");
emit("/* definitions for field: "..field.name.." in reg: "..reg.name.." */");
if(options.c_reg_style == "extended") then
......@@ -40,6 +48,7 @@ function cgen_c_field_define(field, reg, index)
emit(string.format("%-45s %s", "#define "..prefix.."_DESC", "WBGEN2_DESC(\""..field.description:gsub("\n.*", "").."\")"));
emit(string.format("%-45s %s", "#define "..prefix.."_ACCESS", "WBGEN2_"..rw_table[field.access_bus]));
emit(string.format("%-45s %d", "#define "..prefix.."_NBFP", field.nbfp));
emit(string.format("%-45s %d", "#define "..prefix.."_SIGN", field.sign));
if(field.type == BIT or field.type == MONOSTABLE) then
emit(string.format("%-45s %s", "#define "..prefix.."_MASK", "WBGEN2_GEN_MASK("..field.offset..", "..field.size..")"));
emit(string.format("%-45s %d", "#define "..prefix.."_SHIFT", field.offset));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment