Commit 0247d9e4 authored by Dimitris Lampridis's avatar Dimitris Lampridis

proof-of-concept versioning implemented.

For now, the access from the bus is RW, we need to define a new RO/RO mode in wbgen.
parent c906a787
......@@ -117,6 +117,11 @@ function cgen_c_fileheader()
emit("#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<<bits) ? ~((1<<(bits))-1): 0 ) | (value))");
emit("#endif");
emit("");
if (periph.version ~= nil) then
emit("/* version definition */");
emit("#define WBGEN2_"..string.upper(periph.prefix).."_VERSION "..string.format('0x%08X', periph.version));
emit("");
end
end
-- generates C structure reflecting the memory map of the peripheral.
......
......@@ -1883,6 +1883,11 @@ emit("#define WBGEN2_GEN_READ(reg, offset, size) (((reg) >> (offset)) & ((1<<(si
emit("#define WBGEN2_SIGN_EXTEND(value, bits) (((value) & (1<<bits) ? ~((1<<(bits))-1): 0 ) | (value))");
emit("#endif");
emit("");
if(periph.version~=nil)then
emit("/* version definition */");
emit("#define WBGEN2_"..string.upper(periph.prefix).."_VERSION "..string.format('0x%08X',periph.version));
emit("");
end
end
function cgen_c_struct()
local e=0;
......@@ -4332,6 +4337,24 @@ end
parse_args(arg);
dofile(input_wb_file);
if(periph==nil)then die("missing peripheral declaration");end
if(periph.version~=nil)then
table.insert(periph,1,
reg{
name="Version register";
prefix="VER";
field{
name="Version identifier";
prefix="ID";
description="Version identifier for the peripheral";
type=SLV;
size=32;
access_bus=READ_WRITE;
access_dev=READ_ONLY;
reset_value=periph.version;
}
}
);
end
foreach_field(fix_prefix);
foreach_field(fix_access);
foreach_field(check_field_types);
......
......@@ -143,6 +143,24 @@ dofile(input_wb_file);
if(periph == nil) then die ("missing peripheral declaration"); end
if (periph.version ~= nil) then
table.insert(periph, 1,
reg {
name = "Version register";
prefix = "VER";
field {
name = "Version identifier";
prefix = "ID";
description = "Version identifier for the peripheral";
type = SLV;
size = 32;
access_bus = READ_WRITE;
access_dev = READ_ONLY;
reset_value = periph.version;
}
}
);
end
foreach_field( fix_prefix );
foreach_field( fix_access );
......
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