From WikiChip
Module:gpu

To add this template, simple add
{{gpu}}
to the page and save. The chip infobox will have a small [Edit Values] button at the top-right corner which can be used to add values using a form.
local p = {}
local origArgs

function p.add_file_prefix(str)
  if string.match(string.lower(str), '^file:') then
    return str
  else
    return 'File:' .. str
  end
end

function p.add_separator(box, title)
  box:tag('tr')
           :tag('td')
           :attr('class', 'header')
           :attr('colspan', '2')
           :wikitext(title)
end

function p.add_entry(value, right)
  local e = mw.html.create('tr')
  e:tag('td')
    :attr('class', 'label')
    :wikitext(value)
  e:node(right)
  return e   
end

function has_arg(name)
	-- The argument can exist and be empty or not exist at all
	return string.len(origArgs[name] or '') > 0
end

function arg(name)
	return origArgs[name]
end

function p.chip(frame)
	
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame.args
    end
	
	
    local infobox = mw.html.create('table')

    infobox
        :attr('class', 'infobox')
        
    infobox
    	:tag('tr')
			:tag('td'):attr('colspan', '2')
			:tag('small'):attr('style', 'float: right;')
            :wikitext('[[Special:FormEdit/gpu/' .. frame:preprocess('{{FULLPAGENAME}}') .. '|<i class="fa fa-edit"></i>Edit Values]]')
            
    -- header
    if has_arg('name') then
      infobox
        :tag('tr')
          :tag('td')
            :attr('class', 'header-main')
            :attr('colspan', '2')
            :wikitext('[[name::' .. arg('name') .. ']]')
    end
 
    -- some general info first
    p.add_separator(infobox, 'General Info')
    
	-- type
	if has_arg('type') then
		if arg('type') == 'integrated' then
	  		infobox:node(p.add_entry('Type', mw.html.create('td')
	  			:attr('style', 'width: 99%;'):wikitext(
	  			'[[instance of::integrated graphics processor| ]] IGP' ..
    			'[[Category:integrated graphics processor models]]')))
		end
		if arg('type') == 'discrete' then
	  		infobox:node(p.add_entry('Type', mw.html.create('td')
	  			:attr('style', 'width: 99%;'):wikitext(
	  			'[[instance of::discrete graphics processor| ]] DGP' ..
    			'[[Category:discrete graphics processor models]]')))
		end
	end
    
    -- designer
    if has_arg('designer') then
      	local designers = mw.html.create('td'):attr('style', 'width: 99%;')
      	designers:wikitext('[[designer::' .. arg('designer') .. '| ]][[' .. arg('designer') .. ']]' ..
      				'[[category:graphics processor models by ' .. mw.ustring.lower(arg('designer')) .. ']]')
		if has_arg('microarch') then
			designers:wikitext('[[category:graphics processor models by ' .. mw.ustring.lower(arg('designer')) ..
					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
		end
      
      for i = 2, 10 do
      	if not has_arg('designer ' .. i) then break end
      		designers:wikitext(', [[designer::' .. arg('designer ' .. i) .. '| ]][[' .. arg('designer ' .. i) .. ']]' ..
      				'[[category:graphics processor models by ' .. mw.ustring.lower(arg('designer ' .. i)) .. ']]')
  		if has_arg('microarch') then
			designers:wikitext('[[category:graphics processor models by ' .. mw.ustring.lower(arg('designer ' .. i)) ..
  					' based on ' .. mw.ustring.lower(arg('microarch')) .. ']]')
  		end
      end
   	  infobox:node(p.add_entry('Designer', designers))
	end
    
    -- manufacturer
    if has_arg('manufacturer') then
      local manufacturers = '[[manufacturer::' .. arg('manufacturer') .. '| ]][[' .. arg('manufacturer') .. ']]' ..
      		'[[category:graphics processor models by ' .. mw.ustring.lower(arg('manufacturer')) .. ']]'
      		
      for i = 2, 10 do
      	if not has_arg('manufacturer ' .. i) then break end
      	manufacturers = manufacturers .. ', [[manufacturer::' .. arg('manufacturer ' .. i) .. '| ]][[' .. arg('manufacturer ' .. i) .. ']]' ..
      		'[[category:graphics processor models by ' .. mw.ustring.lower(arg('manufacturer ' .. i)) .. ']]'
      end
      
   	  infobox:node(p.add_entry('Manufacturer', mw.html.create('td'):wikitext(manufacturers)))
	end
	
	-- release date
	if has_arg('first launched') or has_arg('first announced') then
	  local release = mw.html.create('td')
	  if has_arg('first announced') then
	    release:wikitext('[[first announced::' .. arg('first announced') .. ']] (announced)')
	  end
	  if has_arg('first launched') then
	  	if has_arg('first announced') then
	  	  release:wikitext('<br>')	
  		end
	    release:wikitext('[[first launched::' .. arg('first launched') .. ']] (launched)')
	  end
	  infobox:node(p.add_entry('Introduction', release))
	end
	
	-- codename
	if has_arg('codename') then
	  infobox:node(p.add_entry('Codename', mw.html.create('td'):wikitext('[[codename::' .. arg('codename') .. '| ]]' .. arg('codename'))))
	end
	
	-- codename
	if has_arg('family') then
	  infobox:node(p.add_entry('Family', mw.html.create('td'):wikitext('[[family name::' .. arg('family') .. '| ]]' .. arg('family'))))
	end
	
    -- ####################################################################
    -- some general info first
    p.add_separator(infobox, 'Microarchitecture')
    
	-- microarch
    if has_arg('microarch') then
      local microarchs = mw.html.create('td')
      microarchs:wikitext('[[microarchitecture::' .. arg('microarch') .. '| ]]')
      microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
      		mw.ustring.lower(arg('microarch')) .. '|' .. arg('microarch') .. ']]')
      for i = 2, 10 do
      	if not has_arg('microarch ' .. i) then break end
      	microarchs:wikitext(', [[microarchitecture::' .. arg('microarch ' .. i) .. '| ]]')
        microarchs:wikitext('[[' .. mw.ustring.lower(arg('designer')) .. '/microarchitectures/' ..
      		mw.ustring.lower(arg('microarch ' .. i)) .. '|' .. arg('microarch ' .. i) .. ']]')
      end
   	  infobox:node(p.add_entry('Microarchitecture', microarchs))
	end
	
	-- exec units
	if has_arg('exec units') then
	  infobox:node(p.add_entry('Execution Units', mw.html.create('td'):wikitext('[[execution units::' .. arg('exec units') .. '| ]]' .. arg('exec units'))))
	end
	
    -- frequency
    if has_arg('frequency') then
      local frequencies = mw.html.create('td'):wikitext('[[base frequency::' .. arg('frequency') .. '| ]]' .. arg('frequency'))
      for i = 2, 10 do
      	if not has_arg('frequency ' .. i) then break end
      	frequencies:wikitext(', [[base frequency::' .. arg('frequency ' .. i) .. '| ]]' .. arg('frequency ' .. i))
      end
   	  infobox:node(p.add_entry('Frequency', frequencies))
	end
	
	
	-- process
    if has_arg('process') then
      local process = mw.html.create('td'):wikitext('[[process::' .. arg('process') .. ']]')
      for i = 2, 10 do
      	if not has_arg('process ' .. i) then break end
      	process:wikitext(', [[process::' .. arg('process ' .. i) .. ']]')
      end
   	  infobox:node(p.add_entry('Process', process))
	end
	
	
	-- Transistors
	if has_arg('transistors') then
	  infobox:node(p.add_entry('Transistors', mw.html.create('td'):wikitext('[[transistor count::' .. arg('transistors') .. ']]')))
	end
	
	-- Technology
	if has_arg('technology') then
	  infobox:node(p.add_entry('Technology', mw.html.create('td'):wikitext('[[technology::' .. arg('technology') .. ']]')))
	end
	
	
	-- die size
	if has_arg('die area') or has_arg('die size') then
		local die
		if has_arg('die size') then
      		die = mw.html.create('td'):wikitext('[[die area::' .. arg('die size') .. ']]')
		else
			die = mw.html.create('td'):wikitext('[[die area::' .. arg('die area') .. ']]')
		end
		if has_arg('die length') and has_arg('die width') then
			die:wikitext('<br>' .. '[[die length::' .. arg('die length') .. '| ]]' ..
						arg('die length') .. ' × [[die width::' .. arg('die width') .. '| ]]' ..
						arg('die width'))	
		end
	  	infobox:node(p.add_entry('Die', die))
	end
	
	-- max memory
	if has_arg('max memory') then
	  infobox:node(p.add_entry('Max Memory', mw.html.create('td'):wikitext('[[max memory::' .. arg('max memory') .. '| ]]' .. arg('max memory'))))
	end
    
    infobox:wikitext('[[full page name::' .. frame:preprocess('{{FULLPAGENAME}}') .. '| ]]')
    
    if has_arg('future') and
    	(string.lower(arg('future')) == 'yes' or string.lower(arg('future')) == 'true') then
    	infobox:wikitext('[[Category:future microprocessor models]][[ldate::3000| ]]')
	elseif has_arg('first launched') then
    	infobox:wikitext('[[ldate::' .. arg('first launched') .. '| ]]')
	elseif has_arg('first announced') then
    	infobox:wikitext('[[ldate::' .. arg('first announced') .. '| ]]')
	else --alright launched but no date?
    	infobox:wikitext('[[ldate::1000| ]]')
    end
	
    return infobox
end

return p