From WikiChip
Difference between revisions of "Module:microarchitecture"

Line 354: Line 354:
 
end
 
end
 
              
 
              
 +
    infobox:wikitext('[[Category:all microarchitectures]]')
 +
    infobox:wikitext('[[full page name::{{FULLPAGENAME}}| ]]')
 +
    infobox:wikitext('[[instance of::microarchitecture| ]]')
 
 
 
return infobox
 
return infobox

Revision as of 04:46, 25 May 2017

Documentation for this module may be created at Module:microarchitecture/doc

local uarch = {}

function add_header_main(box, str)
      box
        :tag('tr')
          :tag('td')
            :attr('class', 'header-main')
            :attr('colspan', '2')
            :wikitext(str)
end
function add_header(box, str)
      box
        :tag('tr')
          :tag('td')
            :attr('class', 'header')
            :attr('colspan', '2')
            :wikitext(str)
end
function add_entry(box, label, value)
      local tag = box:tag('tr')
      
      tag:tag('td')
        :attr('class', 'label')
        :wikitext(label)
        
      tag:tag('td')
        :attr('class', 'value')
        :wikitext(value)
end

function uarch.uarch(frame)
    local infobox = mw.html.create('table')

    infobox
        :attr('class', 'infobox')
        
    -- header
    if string.len(frame.args.name or '') == 0 then return 'ERROR: "name" is missing!' end
	add_header_main(infobox, '[[codename::' .. frame.args.name .. '| ]][[name::' .. frame.args.name .. ']] µarch')

	add_header(infobox, 'General Info')

    -- arch type
    if string.len(frame.args.atype or '') == 0 then return 'ERROR: "atype" is missing!' end
	add_entry(infobox, 'Arch Type', frame.args.atype ..
		'[[microarchitecture type::' .. frame.args.atype .. '| ]]' ..
		'[[Category:' .. string.lower(frame.args.atype) .. ' microarchitectures by ' .. string.lower(frame.args.designer) .. ']]')

	-- designer
    if string.len(frame.args.designer or '') == 0 then return 'ERROR: "designer" is missing!' end
    local devs
    
    devs = '[[designer::' .. string.lower(frame.args.designer) .. '| ]]' .. frame.args.designer
    devs = devs .. '[[Category:microarchitectures by ' .. string.lower(frame.args.designer) .. ']]'
    
    for i = 2, 10 do
    	if string.len(frame.args['designer_' .. i] or '') == 0 then break end
    	devs = devs .. ', [[designer::' .. string.lower(frame.args['designer_' .. i]) .. '| ]]' ..
    			frame.args.designer ..
	    		'[[Category:microarchitectures by ' .. string.lower(frame.args['designer_' .. i]) .. ']]'
	end
	add_entry(infobox, 'Designer', devs)
	
	
	-- manufacturer
    if string.len(frame.args.manufacturer or '') == 0 then return 'ERROR: "manufacturer" is missing!' end
    local devs
    
    devs = '[[manufacturer::' .. string.lower(frame.args.manufacturer) .. '| ]]'
    		.. frame.args.manufacturer
    
    for i = 2, 10 do
    	if string.len(frame.args['manufacturer_' .. i] or '') == 0 then break end
    	devs = devs .. ', [[manufacturer::' .. string.lower(frame.args['manufacturer_' .. i]) .. '| ]]'
    			.. frame.args['manufacturer_' .. i]
	end
	add_entry(infobox, 'Manufacturer', devs)
	
    -- intro
    if string.len(frame.args.introduction or '') > 0 then
		add_entry(infobox, 'Introduction', '[[first launched::' .. frame.args.introduction .. ']]')
	end
	
    -- phase-out
    if string.len(frame.args.phase_out or '') > 0 then
		add_entry(infobox, 'Phase-out', '[[phase-out::' .. frame.args.phase_out .. ']]')
	end
	
	
	
	-- process
    if string.len(frame.args.process or '') > 0 then
	    local proc
	    
	    proc = '[[process::' .. frame.args.process .. '| ]]' ..
	    		'[[' ..  frame.args.process .. ' process|' ..  frame.args.process .. ']]'
	    
	    for i = 2, 10 do
	    	if string.len(frame.args['process_' .. i] or '') == 0 then break end
	    	proc = proc .. ', [[process::' ..frame.args['process_' .. i] .. '| ]]'
	    			.. '[['..  frame.args['process_' .. i] .. ' process|' .. frame.args['process_' .. i] .. ']]'
		end
		add_entry(infobox, 'Process', proc)
	end	
	
	
	-- cores
    if string.len(frame.args.cores or '') > 0 then
	    local core
	    
	    core = '[[core count::' .. frame.args.cores .. '| ]]'
	    	.. '[[' .. frame.args.cores .. ' cores|' .. frame.args.cores .. ']]'
	    
	    for i = 2, 10 do
	    	if string.len(frame.args['cores_' .. i] or '') == 0 then break end
	    	core = core .. ', [[core count::' ..frame.args['cores_' .. i] .. '| ]]'
	    		.. '[[' .. frame.args['cores_' .. i] .. ' cores|' .. frame.args['cores_' .. i] .. ']]'
		end
		add_entry(infobox, 'Core Configs', core)
	end
	
	
	add_header(infobox, 'Pipeline')
	
	-- type
    if string.len(frame.args.ptype or '') > 0 then
	    local ptype
	    
	    ptype = frame.args.ptype
	    for i = 2, 10 do
	    	if string.len(frame.args['ptype_' .. i] or '') == 0 then break end
	    	ptype = ptype .. ', ' .. frame.args['ptype_' .. i]
		end
		add_entry(infobox, 'Type', ptype)
	end
	
    -- oooe
    if string.len(frame.args.oooe or '') > 0 then
		add_entry(infobox, 'OoOE', frame.args.oooe)
	end
	
    -- speculative
    if string.len(frame.args.speculative or '') > 0 then
		add_entry(infobox, 'Speculative', frame.args.speculative)
	end
	
    -- reg_renaming
    if string.len(frame.args.reg_renaming or '') > 0 then
		add_entry(infobox, 'Reg Renaming', frame.args.reg_renaming)
	end
	
    -- pstage
    if string.len(frame.args.pstage or '') > 0 then
		add_entry(infobox, 'Stages', '[[pipeline stages::' .. frame.args.pstage .. ']]')
	end
	
    -- pstage min/max
    if string.len(frame.args.pstages_min or '') > 0 then
		add_entry(infobox, 'Stages',
			'[[pipeline stages (min)::' .. frame.args.pstages_min .. ']]'
			.. '-[[pipeline stages (max)::' .. frame.args.pstages_max .. ']]')
	end
	
    -- decode
    if string.len(frame.args.decode or '') > 0 then
		add_entry(infobox, 'Decode', frame.args.decode)
	end
	
	
	add_header(infobox, 'Instructions')
	
	-- ISA
    if string.len(frame.args.isa or '') > 0 then
	    local isa
	    
	    isa = '[[instruction set architecture::' .. frame.args.isa .. ']]'
	    for i = 2, 10 do
	    	if string.len(frame.args['isa_' .. i] or '') == 0 then break end
	    	isa = isa .. ', ' .. '[[instruction set architecture::' .. frame.args['isa_' .. i] .. ']]'
		end
		add_entry(infobox, 'ISA', isa)
	end
	
	-- features
    if string.len(frame.args.features or '') > 0 then
	    local features
	    
	    features = frame.args.features
	    for i = 2, 10 do
	    	if string.len(frame.args['features_' .. i] or '') == 0 then break end
	    	features = features .. ', ' .. frame.args['features_' .. i]
		end
		add_entry(infobox, 'Features', features)
	end
	
	-- extensions
    if string.len(frame.args.extensions or '') > 0 then
	    local extensions
	    
	    extensions = frame.args.extensions
	    for i = 2, 40 do
	    	if string.len(frame.args['extensions_' .. i] or '') == 0 then break end
	    	extensions = extensions .. ', ' .. frame.args['extensions_' .. i]
		end
		add_entry(infobox, 'Extensions', extensions)
	end
	
	add_header(infobox, 'Cache')
	
    -- L1i
    if string.len(frame.args.l1i or '') > 0 then
    	local li = frame.args.l1i
    	if string.len(frame.args.l1i_per or '') > 0 then
    		li = li .. '/' .. frame.args.l1i_per
		end
    	if string.len(frame.args.l1i_desc or '') > 0 then
    		li = li .. '<br>' .. frame.args.l1i_desc
		end
		add_entry(infobox, 'L1I Cache',  li)
	end
	
    -- L1d
    if string.len(frame.args.l1d or '') > 0 then
    	local li = frame.args.l1d
    	if string.len(frame.args.l1d_per or '') > 0 then
    		li = li .. '/' .. frame.args.l1d_per
		end
    	if string.len(frame.args.l1d_desc or '') > 0 then
    		li = li .. '<br>' .. frame.args.l1d_desc
		end
		add_entry(infobox, 'L1D Cache',  li)
	end
	
    -- L2
    if string.len(frame.args.l2 or '') > 0 then
    	local l2 = frame.args.l2
    	if string.len(frame.args.l2_per or '') > 0 then
    		l2 = l2 .. '/' .. frame.args.l2_per
		end
    	if string.len(frame.args.l2_desc or '') > 0 then
    		l2 = l2 .. '<br>' .. frame.args.l2_desc
		end
		add_entry(infobox, 'L2 Cache',  l2)
	end
	
    -- L3
    if string.len(frame.args.l3 or '') > 0 then
    	local l3 = frame.args.l3
    	if string.len(frame.args.l3_per or '') > 0 then
    		l3 = l3 .. '/' .. frame.args.l3_per
		end
    	if string.len(frame.args.l3_desc or '') > 0 then
    		l3 = l3 .. '<br>' .. frame.args.l3_desc
		end
		add_entry(infobox, 'L3 Cache',  l3)
	end
	
    -- L4
    if string.len(frame.args.l4 or '') > 0 then
    	local l4 = frame.args.l4
    	if string.len(frame.args.l4_per or '') > 0 then
    		l4 = l4 .. '/' .. frame.args.l4_per
		end
    	if string.len(frame.args.l4_desc or '') > 0 then
    		l4 = l4 .. '<br>' .. frame.args.l4_desc
		end
		add_entry(infobox, 'L4 Cache',  l4)
	end
	
    -- Size $
    if string.len(frame.args.sizecache or '') > 0 then
    	local sizecache = frame.args.sizecache
    	if string.len(frame.args.sizecache_per or '') > 0 then
    		sizecache = sizecache .. '/' .. frame.args.sizecache_per
		end
    	if string.len(frame.args.sizecache_desc or '') > 0 then
    		sizecache = sizecache .. '<br>' .. frame.args.sizecache_desc
		end
		add_entry(infobox, 'Size Cache',  sizecache)
	end
	
	
	add_header(infobox, 'Cores')
	
	
	-- cores
    if string.len(frame.args.core_name or '') > 0 then
	    local cores
	    
	    cores = frame.args.core_name
	    for i = 2, 10 do
	    	if string.len(frame.args['core_name_' .. i] or '') == 0 then break end
	    	cores = cores .. ', ' .. frame.args['core_name_' .. i]
		end
		add_entry(infobox, 'Core Names', features)
	end
	
	if string.len(frame.args.successor or '') > 0
	or string.len(frame.args.predecessor or '') > 0 then
		add_header(infobox, 'Succession')
		
		local s = infobox:tag('tr')
		local d1 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex;')
		local d2 = s:tag('td'):tag('div'):attr('style', 'display: inline-flex; float: right;')
		if string.len(frame.args.predecessor or '') > 0 then
			
		    local list
		    if string.len(frame.args.predecessor_link or '') > 0 then
				list = '[[' .. frame.args.predecessor_link .. '|' .. frame.args.predecessor .. ']]'
			else
				list = '[[' .. frame.args.predecessor .. ']]'
			end
		    for i = 2, 10 do
		    	if string.len(frame.args['predecessor_' .. i] or '') == 0 then break end
		    	if string.len(frame.args['predecessor_link_' .. i] or '') then
		    		list = list .. '[[' .. frame.args['predecessor_link_' .. i] .. '|' ..
		    			frame.args['predecessor_' .. i] .. ']]'
	    		else
		    		list = list .. '[[' .. frame.args['predecessor_' .. i] .. ']]'
    			end
			end
			
			d1:tag('div')
				:attr('style', 'float: left; padding-right: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-left"></i>')
			d1:tag('div')
				:attr('style', 'float: left;')
				:wikitext(list)
		end
		if string.len(frame.args.successor or '') > 0 then
			local list
		    if string.len(frame.args.successor_link or '') > 0 then
				list = '[[' .. frame.args.successor_link .. '|' .. frame.args.successor .. ']]'
			else
				list = '[[' .. frame.args.successor .. ']]'
			end
		    for i = 2, 10 do
		    	if string.len(frame.args['successor_' .. i] or '') == 0 then break end
		    	if string.len(frame.args['successor_link_' .. i] or '') then
		    		list = list .. '[[' .. frame.args['successor_link_' .. i] .. '|' ..
		    			frame.args['successor_' .. i] .. ']]'
	    		else
		    		list = list .. '[[' .. frame.args['successor_' .. i] .. ']]'
    			end
			end
			
			d2:tag('div')
				:attr('style', 'float: left;')
				:wikitext('[[test]]')
			d2:tag('div')
				:attr('style', 'float: right; padding-left: 10px; margin: auto 5px;')
				:wikitext('<i class="fa fa-chevron-right"></i>')
		end
	end
            
    infobox:wikitext('[[Category:all microarchitectures]]')
    infobox:wikitext('[[full page name::{{FULLPAGENAME}}| ]]')
    infobox:wikitext('[[instance of::microarchitecture| ]]')
	
	return infobox
end

return uarch